#include <iostream>

using namespace std;

typedef long long LL;

int gcd, lcm;

int f(int x, int y)
{
	return y == 0 ? x : f(y, x % y);
}

int main()
{
	cin >> gcd >> lcm;
	LL sum = gcd * lcm;
	int cnt = 0;
	for(int i = gcd; i <= lcm; i++)
	{
		if(sum % i != 0) continue;
		int j = sum / i;
		if(f(i, j) == gcd) cnt++;
	}
	cout << cnt << endl;
	return 0;
}
